# 
#load results from alpha0_calculation.R, which have been save as "ca1.xlsx","ca10.xlsx","ca30.xlsx" and "ca50.xlsx"
#
library(ggplot2)
library(xlsx)
library("gridExtra")

la1 = read.xlsx("ca1.xlsx",1)
la10 = read.xlsx("ca10.xlsx",1)
la30 = read.xlsx("ca30.xlsx",1)
la50 = read.xlsx("ca50.xlsx",1)

r1 = ggplot(la1,aes(lv,ca)) + theme_classic() +  xlim(min(la1$lv),max(la1$lv)) + ylim(0.04,max(la1$ca)) + 
  geom_point() + geom_hline(yintercept=0.05, linetype="dashed")+ scale_y_continuous(labels = scales::percent)+
  labs(title=expression(H[R[1]]), x="level", y = expression(alpha[0])) +
  theme(plot.title = element_text(hjust = 0.5, face="bold",size=16)) 


r10 = ggplot(la10,aes(lv,ca)) + theme_classic() +  xlim(min(la10$lv),max(la10$lv)) + ylim(0.04,max(la10$ca)) + 
  geom_point() + geom_hline(yintercept=0.05, linetype="dashed")+ scale_y_continuous(labels = scales::percent)+
  labs(title=expression(H[R[10]]), x="level", y = expression(alpha[0])) +
  theme(plot.title = element_text(hjust = 0.5, face="bold",size=16))
r30 = ggplot(la30,aes(lv,ca)) + theme_classic() +  xlim(min(la30$lv),max(la30$lv)) + ylim(0.04,max(la30$ca)) + 
  geom_point() + geom_hline(yintercept=0.05, linetype="dashed")+scale_y_continuous(labels = scales::percent)+
  labs(title=expression(H[R[30]]), x="level", y = expression(alpha[0])) +
  theme(plot.title = element_text(hjust = 0.5, face="bold",size=16))
r50 = ggplot(la50,aes(lv,ca)) + theme_classic() +  xlim(min(la50$lv),max(la50$lv)) + ylim(0.04,max(la50$ca)) + 
  geom_point() + geom_hline(yintercept=0.05, linetype="dashed")+scale_y_continuous(labels = scales::percent)+
  labs(title=expression(H[R[50]]), x="level", y = expression(alpha[0])) +
  theme(plot.title = element_text(hjust = 0.5, face="bold",size=16))


jpeg("a0.jpg",width = 16, height = 12, units = 'cm', res = 600)
grid.arrange(r1,r10,r30,r50, ncol = 2, nrow = 2)
dev.off()




